﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefQcTemplate" :model="stateQcTemplate.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Name_FormItem" prop="Entity.Name" :label="$t('message.autotrans._Model_QcTemplate_Name')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_QcTemplate_Name')}), trigger: 'blur' }]" >
            <el-input v-model="stateQcTemplate.vmModel.Entity.Name" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Code_FormItem" prop="Entity.Code" :label="$t('message.autotrans._Model_QcTemplate_Code')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_QcTemplate_Code')}), trigger: 'blur' }]" >
            <el-input v-model="stateQcTemplate.vmModel.Entity.Code" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductId_FormItem" prop="Entity.ProductId" :label="$t('message.autotrans._Model_QcTemplate_ProductId')">
            <el-input v-model="stateQcTemplate.vmModel.Entity.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductionName_FormItem" prop="Entity.ProductionName" :label="$t('message.autotrans._Model_QcTemplate_ProductionName')">
            <el-input v-model="stateQcTemplate.vmModel.Entity.ProductionName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_QcMode_FormItem" prop="Entity.QcMode" :label="$t('message.autotrans._Model_QcTemplate_QcMode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_QcTemplate_QcMode')}), trigger: 'blur' }]" >
            <el-select v-model="stateQcTemplate.vmModel.Entity.QcMode" clearable>
               <el-option key="IQC" value="IQC" :label="$t('message.autotrans._Enum_QcModeEnum_IQC')"></el-option>
               <el-option key="IPQC" value="IPQC" :label="$t('message.autotrans._Enum_QcModeEnum_IPQC')"></el-option>
               <el-option key="FQC" value="FQC" :label="$t('message.autotrans._Enum_QcModeEnum_FQC')"></el-option>
               <el-option key="OQC" value="OQC" :label="$t('message.autotrans._Enum_QcModeEnum_OQC')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
      </el-row>

      <WtmTable ref="tableRefQcInspectItemTemplateList" v-bind="tableDataQcInspectItemTemplateList" v-model="stateQcTemplate.vmModel.Entity.QcInspectItem_Template"></WtmTable>
      <div style="text-align:right;">
        <WtmButton @click="onSubmitQcTemplate"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

        <WtmButton @click="onCloseQcTemplate"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageQcManagementQcTemplateCreate;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { qctemplateApi } from '/@/api/qcmanagement/qctemplate';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const tableRefQcInspectItemTemplateList = ref();
const tableDataQcInspectItemTemplateList = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page检验分类'),key: 'QcType',type: 'combobox',comboData:{
                Equipment:ci.proxy.$t('message.autotrans._Enum_EquipTypeEnum_Equipment'),
                Tooling:ci.proxy.$t('message.autotrans._Enum_EquipTypeEnum_Tooling'),
                Mould:ci.proxy.$t('message.autotrans._Enum_EquipTypeEnum_Mould'),},isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page检验项目'),key: 'InspectName',type: 'textbox',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page检测工具'),key: 'InspectTool',type: 'textbox',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page检验内容'),key: 'Content',type: 'textbox',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page参考值'),key: 'RefValue',type: 'textbox',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminRemark'),key: 'Remark',type: 'textbox',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: false, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
        isSub:true,
        isDisabled:false
	}
});

// 定义变量内容
const formRefQcTemplate = ref();
const stateQcTemplate = reactive({
    vmModel: {
	  Entity:{
        Name: '',
        Code: '',
        ProductId: null,
        ProductionName: '',
        QcMode: undefined,
        QcInspectItem_Template:[],
      },

	},
    
    AllTemplates: [] as any[],
});

// 取消
const onCloseQcTemplate = () => {
    closeDialog();
};

// 提交
const onSubmitQcTemplate = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefQcTemplate.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            qctemplateApi().add(stateQcTemplate.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/QcManagement/QcInspectItem/GetQcTemplates',[],false).then(x=>{stateQcTemplate.AllTemplates = x});
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

